﻿using UnityEngine;
using UnityEngine.UI;

namespace DiverseStudents.UI
{
    internal static partial class UICreate
    {

        public static Toggle DefaultToggle(string flag = "",bool isClick = true, float heigth = 40, float width = 40, bool _show = true)
        {
            GameObject gameObject = new GameObject($"Mod_Toggle{flag}", typeof(Toggle));
            // GameObject gameObject2 = new GameObject($"Toggle{flag}back",typeof(Image));
            GameObject gameObject3 = new GameObject($"Toggle{flag}Check", typeof(Image));
            var toggle = gameObject.GetComponent<Toggle>();
            var checkImg = gameObject3.GetComponent<Image>();
            
            checkImg.rectTransform.sizeDelta = new Vector2(width, heigth);
            checkImg.color = new Color(0.244f, 0.538f, 0.244f);
            checkImg.rectTransform.anchorMin = new Vector2(0.5f, 0.5f);
            checkImg.rectTransform.anchorMax = new Vector2(0.5f, 0.5f);
            checkImg.transform.SetParent(gameObject.transform, false);
            toggle.targetGraphic = checkImg;
            toggle.isOn = isClick;
            gameObject.SetActive(_show);
            return toggle;
        }
    }
}
